import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/account_entity.dart';

AccountEntity $AccountEntityFromJson(Map<String, dynamic> json) {
  final AccountEntity accountEntity = AccountEntity();
  final AccountBalance? balance = jsonConvert.convert<AccountBalance>(
      json['balance']);
  if (balance != null) {
    accountEntity.balance = balance;
  }
  final AccountMargin? margin = jsonConvert.convert<AccountMargin>(
      json['margin']);
  if (margin != null) {
    accountEntity.margin = margin;
  }
  return accountEntity;
}

Map<String, dynamic> $AccountEntityToJson(AccountEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['balance'] = entity.balance?.toJson();
  data['margin'] = entity.margin?.toJson();
  return data;
}

extension AccountEntityExtension on AccountEntity {
  AccountEntity copyWith({
    AccountBalance? balance,
    AccountMargin? margin,
  }) {
    return AccountEntity()
      ..balance = balance ?? this.balance
      ..margin = margin ?? this.margin;
  }
}

AccountBalance $AccountBalanceFromJson(Map<String, dynamic> json) {
  final AccountBalance accountBalance = AccountBalance();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    accountBalance.total = total;
  }
  final String? sumAmount = jsonConvert.convert<String>(json['sumAmount']);
  if (sumAmount != null) {
    accountBalance.sumAmount = sumAmount;
  }
  final String? plusAmount = jsonConvert.convert<String>(json['plusAmount']);
  if (plusAmount != null) {
    accountBalance.plusAmount = plusAmount;
  }
  final String? minusAmount = jsonConvert.convert<String>(json['minusAmount']);
  if (minusAmount != null) {
    accountBalance.minusAmount = minusAmount;
  }
  final List<AccountBalanceData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<AccountBalanceData>(e) as AccountBalanceData)
      .toList();
  if (data != null) {
    accountBalance.data = data;
  }
  return accountBalance;
}

Map<String, dynamic> $AccountBalanceToJson(AccountBalance entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['sumAmount'] = entity.sumAmount;
  data['plusAmount'] = entity.plusAmount;
  data['minusAmount'] = entity.minusAmount;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension AccountBalanceExtension on AccountBalance {
  AccountBalance copyWith({
    int? total,
    String? sumAmount,
    String? plusAmount,
    String? minusAmount,
    List<AccountBalanceData>? data,
  }) {
    return AccountBalance()
      ..total = total ?? this.total
      ..sumAmount = sumAmount ?? this.sumAmount
      ..plusAmount = plusAmount ?? this.plusAmount
      ..minusAmount = minusAmount ?? this.minusAmount
      ..data = data ?? this.data;
  }
}

AccountBalanceData $AccountBalanceDataFromJson(Map<String, dynamic> json) {
  final AccountBalanceData accountBalanceData = AccountBalanceData();
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    accountBalanceData.uid = uid;
  }
  final String? amount = jsonConvert.convert<String>(json['amount']);
  if (amount != null) {
    accountBalanceData.amount = amount;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    accountBalanceData.name = name;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    accountBalanceData.mobile = mobile;
  }
  return accountBalanceData;
}

Map<String, dynamic> $AccountBalanceDataToJson(AccountBalanceData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['amount'] = entity.amount;
  data['name'] = entity.name;
  data['mobile'] = entity.mobile;
  return data;
}

extension AccountBalanceDataExtension on AccountBalanceData {
  AccountBalanceData copyWith({
    String? uid,
    String? amount,
    String? name,
    String? mobile,
  }) {
    return AccountBalanceData()
      ..uid = uid ?? this.uid
      ..amount = amount ?? this.amount
      ..name = name ?? this.name
      ..mobile = mobile ?? this.mobile;
  }
}

AccountMargin $AccountMarginFromJson(Map<String, dynamic> json) {
  final AccountMargin accountMargin = AccountMargin();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    accountMargin.total = total;
  }
  final String? sumAmount = jsonConvert.convert<String>(json['sumAmount']);
  if (sumAmount != null) {
    accountMargin.sumAmount = sumAmount;
  }
  final List<AccountMarginData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<AccountMarginData>(e) as AccountMarginData)
      .toList();
  if (data != null) {
    accountMargin.data = data;
  }
  return accountMargin;
}

Map<String, dynamic> $AccountMarginToJson(AccountMargin entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['sumAmount'] = entity.sumAmount;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension AccountMarginExtension on AccountMargin {
  AccountMargin copyWith({
    int? total,
    String? sumAmount,
    List<AccountMarginData>? data,
  }) {
    return AccountMargin()
      ..total = total ?? this.total
      ..sumAmount = sumAmount ?? this.sumAmount
      ..data = data ?? this.data;
  }
}

AccountMarginData $AccountMarginDataFromJson(Map<String, dynamic> json) {
  final AccountMarginData accountMarginData = AccountMarginData();
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    accountMarginData.uid = uid;
  }
  final String? amount = jsonConvert.convert<String>(json['amount']);
  if (amount != null) {
    accountMarginData.amount = amount;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    accountMarginData.name = name;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    accountMarginData.mobile = mobile;
  }
  return accountMarginData;
}

Map<String, dynamic> $AccountMarginDataToJson(AccountMarginData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['amount'] = entity.amount;
  data['name'] = entity.name;
  data['mobile'] = entity.mobile;
  return data;
}

extension AccountMarginDataExtension on AccountMarginData {
  AccountMarginData copyWith({
    String? uid,
    String? amount,
    String? name,
    String? mobile,
  }) {
    return AccountMarginData()
      ..uid = uid ?? this.uid
      ..amount = amount ?? this.amount
      ..name = name ?? this.name
      ..mobile = mobile ?? this.mobile;
  }
}